package com.shg.web.ztest;



import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shg.bean.Power;
import com.shg.service.PowerService;
import com.shg.web.mail.action.RetrievePassWordAction;

public class PowerServiceTest {

	static PowerService powerService;
	
	static RetrievePassWordAction passWordAction;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ApplicationContext context=new ClassPathXmlApplicationContext("basics-application.xml");
		powerService=(PowerService) context.getBean("powerServiceBean");
		passWordAction = (RetrievePassWordAction) context.getBean("retrievePassWordAction");
	}

	@Test
	public void testMail(){
		passWordAction.sendMail("941376006@QQ.com", "测试", "我的内容");
	}
	@Test
	public void testInsert() {
		Power entity=new Power();
		entity.setName("角色修改");
		entity.setParent(3);
		entity.setUrl("/control/mapping/admin_editAdminForRole.go");
		entity.setRemarks("该指定用户的角色");
		powerService.insert(entity);
	}

	@Test
	public void update(){
//		Power power=new Power();
//		power.setId(46);
//		power.setName("xxxxx");
//		power.setUrl("xxxxxxxxxxx");
//		power.setRemarks("这是背景吗");
//		powerService.updatePower(power);
		
		Power power=new Power();
		power.setId(5);
		long [] x=new long[1];
		x[0]=1;
		try {
			powerService.updatePowerForRole(power,x);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		//powerService.updateUnlock(0, 46);
	}
}
